package com.cdx.spring.beanpost;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @author chedx
 * @data 2021/1/10 1:24 PM
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }

    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {


        if (bean instanceof Categroy) {
            Categroy categroy  = (Categroy)bean;
            categroy.setName("xiaowb");
            return categroy;
        }
        return bean;
    }
}
